package com.entor.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSON;
import com.entor.model.Finance;
import com.entor.model.Msg;
import com.entor.service.FinanceService;

@RequestMapping("/fc")
@Controller
public class FinanceController extends BaseController<Finance>{
	
	@Autowired
	private FinanceService fsi;
	
	@RequestMapping("/index")
	public String index() {
		return "/finance/index";
	}
	
	@Override
	public List<Finance> find(Finance t) {
		return fsi.find(t);
	}
	
	@RequestMapping("/aoe.coc")
	public String addOrEdit(String fid,HttpServletRequest req) throws Exception {
		Finance f = new Finance();
		f.setId(Integer.parseInt(fid));
		f = fsi.get(f);
		req.setAttribute("fin",f);
		return "/finance/addOrEdit";
	}
	
	@Override
	public Msg insert(Finance t) {
		return fsi.insert(t);
	}
	
	@Override
	public Msg edit(Finance t,@RequestParam(required=false,value="file") MultipartFile[] files) {
		return fsi.edit(t);
	}
	
	@Override
	public Msg remove(@PathVariable(value="id")Integer id) {
		return fsi.remove(id);
	}
	
	@RequestMapping("/batchDel")
	@ResponseBody
	public Msg batchDel(String ids) {
		return fsi.batchRemove(ids);
	}
}
